<?php

// +---------------------------------------------------------
// | Name: 星空框架 产品验证规则
// +---------------------------------------------------------
// | Version: V5.0
// +---------------------------------------------------------
// | Author: xkyinzhe <zhonghuaxinxing@sina.cn>
// +---------------------------------------------------------
// | Time： 2021-04-26 16:41
// +---------------------------------------------------------
declare(strict_types=1);

namespace app\common\validate;

use think\Validate;
use app\common\model\Goods AS GoodsModel;

/**
 * @xk 产品验证规则
 */
class Goods extends Validate
{
    protected $rule = [
    'goods_id' => 'number|min:1',
    'goods_cate_id' => 'require|number|min:1',
    'goods_name' => 'require|min:2|max:100',
    'store_id' => 'require|number|min:1',
    'goods_sn' => 'require|unique:goods',
    'picurl' => 'require',
    'pic_arr' => 'requireWithout:fileurl',
    'fileurl' => 'requireWithout:pic_arr',
    'selling_price' => 'require|float|between:0,9999999999999999.99',
    'market_price' => 'require|float|between:0,9999999999999999.99',
    'achievement_bili' => 'require|float|between:0,9999999999999999.99',
    'stock' => 'number|between:1,99999999999999',
    'order_id' => 'require|number|min:1',
    'is_onsell' => 'require|number|in:0,1',
    'is_new' => 'require|number|in:0,1',
    'is_tj' => 'require|number|in:0,1',
  ];
    protected $message = [
    'goods_id' => '请选择需要保存的产品',
    'goods_cate_id' => '请选择产品所属分类',
    'store_id' => '请选择产品所属店铺',
    'goods_name' => '请填写产品名称',
    'goods_sn' => '商品条码有重复，请重新填写',
    'picurl' => '请上传产品图片',
    'pic_arr' => '请上传一张组图或产品视频',
    'fileurl' => '请上传一张组图或产品视频',
    'selling_price' => '产品售价区间应该为【0.01-9999999999999999.9999】',
    'market_price' => '产品市场价区间应该为【0.01-9999999999999999.9999】',
    'achievement_bili' => '产品业绩金额区间应该为【0.01-99999999999999.99】',
    'stock' => '请输入产品库存,产品库存区间应该为【1-99999999999999】',
    'order_id' => '产品排序为大于0的正整数',
    'is_onsell' => '是否上架不符合规则',
    'is_new' => '是否新品不符合规则',
    'is_tj' => '是否推荐不符合规则',
  ];

    protected $scene = [
    'create' => ['goods_cate_id','store_id', 'goods_name', 'picurl', 'goods_sn', 'fileurl', 'pic_arr', 'selling_price','stock', 'achievement_bili', 'order_id', 'is_onsell', 'is_new', 'is_tj'],
    'edit' => ['goods_id', 'goods_cate_id', 'goods_name', 'picurl', 'goods_sn', 'fileurl', 'pic_arr', 'selling_price', 'achievement_bili', 'order_id', 'is_onsell', 'is_tj'],
  ];
}
